package BinarySearchTree;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-06-29
 * Time: 19:03
 */
public class Test {
    public static void main(String[] args) {
        int[] arr={10,4,29,35,18,27,5,13};
        int len=arr.length;
        BinarySearchTree binarySearchTree=new BinarySearchTree();
        for (int i = 0; i < len; i++) {
            binarySearchTree.insert(arr[i]);
        }
        BinarySearchTree.TreeNode root2=binarySearchTree.root;
        binarySearchTree.inorder(root2);
        System.out.println();
        System.out.println("查找");
        BinarySearchTree.TreeNode ret=binarySearchTree.search(10);
        BinarySearchTree.TreeNode ret2=binarySearchTree.searchDiGui(root2,18);
        try{
            System.out.println("查找成功"+ret.key);
            System.out.println("查找成功"+ret2.key);
        }catch (NullPointerException e){
            System.out.println("没有该节点");
            e.printStackTrace();
        }
        binarySearchTree.remove(10);
    }
}
